<template>
  <div class="clearfix">
    <tableComponents :pagination="{
        currentPage,
        pageSize: pagesize,
        total: shop_list.all_num,
      }" @handleCurrentChange="handleCurrentChange" @handleSizeChange="handleSizeChange" :isHaveExport="false" :isShow="true" :isHaveAdd="
        $route.query.action == 1 || $route.query.action == 39 || $route.query.action == 63|| $route.query.action == 23|| $route.query.action == 42 ? true : false
      " @toAdd="add_btn" @sendUserSearch="getSearch" :searchData="actionSearchData">
      <template v-slot:headRight>
        <div class="fx head-right-icon" @click="cjjhgylcp" v-if="
            $store.state.plugin &&
            $store.state.plugin.jhgyl &&
            $store.state.plugin.jhgyl.is_open == 1 &&
            $route.query.action == 34
          ">
          <p><i class="el-icon-coordinate"></i>&nbsp;&nbsp;获取供应链商品</p>
        </div>
        <div class="fx head-right-icon" @click="clearshop" v-if="
            $store.state.plugin &&
            $store.state.plugin.jhgyl &&
            $store.state.plugin.jhgyl.is_open == 1 &&
            $route.query.action == 34
          ">
          <p>
            <i class="el-icon-close" />
            &nbsp;&nbsp;清空商品
          </p>
        </div>
      </template>
      <template v-slot:table>
        <el-table ref="multipleTable" stripe v-loading="loading" header-row-class-name="head_color" :data="shop_list.data" tooltip-effect="dark" style="width: 99.8%" :default-sort="{ prop: 'sort' }" @selection-change="handleSelectionChange">
          <el-table-column type="selection" class="tc" width="35"></el-table-column>
          <el-table-column prop="sort" sortable :sort-method="sorta" label="排序" min-width="80">
            <template slot-scope="scope">
              <el-input @change="sortNew(scope.$index, scope.row)" v-model.number="scope.row.sort" autocomplete="off" size="small"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="商品图片" width="200" align="center">
            <template slot-scope="scope">
              <el-popover placement="right" title trigger="hover">
                <img :src="scope.row.piclink" style="width: 500px" />
                <img slot="reference" :src="scope.row.piclink" :alt="scope.row.piclink" style="width: 100px" />
              </el-popover>
            </template>
          </el-table-column>

          <el-table-column label="标题" min-width="220">
            <template slot-scope="scope">
              <div class="tab_div" style="vertical-align: text-top">
                <div>
                  <span>商品标题：</span>
                  <span>{{ scope.row.title }}</span>
                </div>
                <div>
                  <span>商品分类：</span>
                  <span>{{ scope.row.cate_title }}</span>
                </div>
                <div v-if="scope.row.label && scope.row.label.length > 0">
                  <span>商品标签：</span>
                  <el-tag v-for="(label, l) in scope.row.label" style="margin-right: 5px; color: #ffffff; margin-left: 0" size="mini" :key="l" effect="dark">{{ label }}</el-tag>
                </div>
                <div>
                  <span></span>
                  <span class="rat" v-show="scope.row.is_exchange == '1'">积分兑换</span>
                  <span class="rat mar_lf_15" v-show="scope.row.is_publicflat == '1'">公排</span>
                </div>
              </div>
            </template>
          </el-table-column>

          <el-table-column label="售价" min-width="120">
            <template slot-scope="scope">
              <div class="tab_div">
                <div>
                  <span>售价：</span>
                  <span>{{ scope.row.price }}</span>
                </div>
                <div>
                  <span>成本价：</span>
                  <span>{{ scope.row.cost_price }}</span>
                </div>
                <div>
                  <span>PV值：</span>
                  <span>{{ scope.row.pv }}</span>
                </div>
              </div>
            </template>
          </el-table-column>

          <el-table-column label="商品信息" min-width="120">
            <template slot-scope="scope">
              <div class="tab_div">
                <div>
                  <span>真实销量：</span>
                  <span>{{ scope.row.real_sale }}</span>
                </div>
                <div>
                  <span>库存总量：</span>
                  <span>{{ scope.row.stock }}</span>
                </div>
                <div>
                  <span>赠送积分：</span>
                  <span>{{ scope.row.send_score }}</span>
                </div>
              </div>
            </template>
          </el-table-column>
          <el-table-column label="活动信息" min-width="260">
            <template slot-scope="scope">
              <div class="tab_div">
                <div v-if="scope.row.hyzq_jlzq > 0">
                  <span>赠送天数：</span>
                  <span>{{scope.row.hyzq_jlzq}}天</span>
                </div>
                <div v-if="scope.row.hyzq_mtjl > 0">
                  <span>每天赠送：</span>
                  <span>{{scope.row.hyzq_mtjl}}积分</span>
                </div>
                <div v-if="scope.row.hyzq_qylx == 1 || scope.row.hyzq_qylx == 2">
                  <span>所属版块：</span>
                  <el-tag v-if="scope.row.hyzq_qylx == 1" size="mini" style="color:#409EFF">权益板块</el-tag>
                  <el-tag v-else-if="scope.row.hyzq_qylx == 2" size="mini" type="warning" style="color:#EBB563">认筹板块</el-tag>
                </div>
                <div v-if="$route.query.action == 7">
                  <span style="font-weight: bold">限时特惠：</span>
                  <span>{{ scope.row.discount_rob }}折</span>
                  <br />
                  <span style="font-weight: bold">折扣价格：</span>
                  <span>{{ scope.row.limited_price }}元</span>
                  <br />
                  <span style="font-weight: bold">限购数量：</span>
                  <span>{{ scope.row.discount_limit }}</span>
                  <br />
                  <span style="font-weight: bold">优惠时间：</span>
                  <span>{{ scope.row.rob_time_begin | getTimeFormat }}---{{
                      scope.row.rob_time_end | getTimeFormat
                    }}</span>
                  <br />
                </div>
                <div v-if="$route.query.action == 2">
                  <span style="font-weight: bold">积分兑换：</span>
                  <span>{{ scope.row.score_rob }}</span>
                  <br />
                  <span style="font-weight: bold">积分分类：</span>
                  <span>{{ scope.row.integral_cate_cn }}</span>
                </div>
                <div v-if="$route.query.action == 4">
                  <span style="font-weight: bold">拼团人数：</span>
                  <span>{{ scope.row.group_people }}</span>
                  <br />
                  <span style="font-weight: bold">拼团折扣：</span>
                  <span>{{ scope.row.group_discount | keepTwoNum }}折</span>
                  <br />
                  <span style="font-weight: bold">拼团时间：</span>
                  <span>{{ scope.row.group_time }}小时</span>
                  <br />
                  <span style="font-weight: bold">团长免单：</span>
                  <span>{{ scope.row.group_face == 0 ? "否" : "是" }}</span>
                  <br />
                </div>
                <div v-if="$route.query.action == 8">
                  <span style="font-weight: bold">赠送公排权值：</span>
                  <span>{{ scope.row.platoon | keepTwoNum }}</span>
                </div>
                <div v-if="$route.query.action == 3">
                  <span style="font-weight: bold">砍价次数：</span>
                  <span>{{ scope.row.bargain_number }}次</span>
                  <br />
                  <span style="font-weight: bold">单次最低砍价价格：</span>
                  <span>{{ scope.row.bargain_begin }}元</span>
                  <br />
                  <span style="font-weight: bold">单次最高砍价价格：</span>
                  <span>{{ scope.row.bargain_end }}元</span>
                  <br />
                  <span style="font-weight: bold">最多累计砍价金额：</span>
                  <span>{{ $fnc.toFixedZ(scope.row.bargain_price) }}元</span>
                  <br />
                  <span style="font-weight: bold">时间期限（小时）：</span>
                  <span>{{ scope.row.bargain_time }}小时</span>
                  <br />
                </div>
                <div v-if="$route.query.action == 6">
                  <span style="font-weight: bold">定金：</span>
                  <span>{{ scope.row.down_pay }}元</span>
                  <br />
                  <span style="font-weight: bold">发货期：</span>
                  <span>{{ scope.row.delivery_date | getTimeFormat }}</span>
                  <br />
                  <div class="presale">
                    <span style>单数</span>
                    <span>预售价</span>
                    <div v-for="(item, k) in toParst(scope.row.ladder)" :key="k">
                      <span>{{ item.ladder_num }}单</span>
                      <span>{{ item.ladder_money }}元</span>
                    </div>
                  </div>
                </div>
                <div v-if="$route.query.action == 18">
                  <span style="font-weight: bold">竞拍方式：</span>
                  <span>{{
                    scope.row.auction_types == 0 ? "提价拍" : "降价拍"
                  }}</span>
                  <br />
                  <span style="font-weight: bold">起拍价：</span>
                  <span>{{ $fnc.toFixedZ(scope.row.starting_price) }}元</span>
                  <br />

                  <span style="font-weight: bold">流拍价：</span>
                  <span>{{ $fnc.toFixedZ(scope.row.auction_price) }}元</span>
                  <br />

                  <span style="font-weight: bold">加减幅度：</span>
                  <span>{{ $fnc.toFixedZ(scope.row.auction_amplitude) }} ~
                    {{ $fnc.toFixedZ(scope.row.auction_amplitude_max) }}元</span>
                  <br />

                  <span style="font-weight: bold">保证金：</span>
                  <span>{{ $fnc.toFixedZ(scope.row.auction_margin) }}元</span>
                  <br />

                  <span style="font-weight: bold">开始时间：</span>
                  <span>{{ scope.row.auction_open_time | getTimeFormat }}</span>
                  <br />

                  <span style="font-weight: bold">结束时间：</span>
                  <span>{{ scope.row.auction_end_time }}分钟</span>
                  <br />

                  <span style="font-weight: bold">下一轮开始时间：</span>
                  <span>{{ scope.row.auction_next_time }}分钟</span>
                  <br />
                </div>

                <div v-if="$route.query.action == 19">
                  <span style="font-weight: bold">拼购价格：</span>
                  <span>{{ $fnc.toFixedZ(scope.row.group_buy_price) }}</span>
                  <br />
                  <span style="font-weight: bold">拼购分类：</span>
                  <span>{{ scope.row.group_buy_cate }}</span>
                </div>

                <div v-if="$route.query.action == 24">
                  <span style="font-weight: bold">零元购邮费：</span>
                  <span>{{ $fnc.toFixedZ(scope.row.zeromail) }}</span>
                </div>

                <div v-if="$route.query.action == 10 || $route.query.action == 11">
                  <span style="font-weight: bold">核销次数 ：</span>
                  <span>{{ Number(scope.row.write_number) }}</span>
                  <br />
                  <span style="font-weight: bold">每次核销奖励核销人金额：</span>
                  <span>{{ $fnc.toFixedZ(scope.row.write_reward) }}</span>
                </div>

                <div v-if="$route.query.action == 24">
                  <span style="font-weight: bold">邮费：</span>
                  <span>{{ $fnc.toFixedZ(scope.row.zeromail) }}</span>
                </div>

                <div v-if="$route.query.action == 34">
                  <span style="font-weight: bold">供应链是否包邮：</span>
                  <span>{{ scope.row.jh_is_mail == 1 ? "是" : "否" }}</span>
                  <br />
                  <span style="font-weight: bold">供应链销售价：</span>
                  <span>{{ $fnc.toFixedZ(scope.row.jh_sale_price) }}</span>
                  <br />
                  <span style="font-weight: bold">供应链成本价：</span>
                  <span>{{ $fnc.toFixedZ(scope.row.jh_cost_price) }}</span>
                  <br />
                  <span style="font-weight: bold">聚合供应链ID：</span>
                  <span>{{ scope.row.jh_id }}</span>
                  <br />
                </div>
                <div v-if="$route.query.action == 39">
                  <span style="font-weight: bold">空单费：</span>
                  <span>{{ $fnc.toFixedZ(scope.row.door_price) }}</span>
                  <br />
                  <template v-if="scope.row.door_time > 0">
                    <span style="font-weight: bold">项目工时：</span>
                    <span>{{ scope.row.door_time }}分钟</span>
                    <br />
                  </template>
                </div>
              </div>
            </template>
          </el-table-column>
          <el-table-column label="是否上架" min-width="130" show-overflow-tooltip>
            <template slot-scope="scope">
              <el-switch class="zdySwith" :width="82" v-model="scope.row.show" active-color="#1aad19" inactive-color="#ffffff" active-text="上架" inactive-text="不上架" active-value="1" @change="getIsup(scope.row)" inactive-value="0"></el-switch>
            </template>
          </el-table-column>

          <el-table-column label="是否审核" min-width="130" show-overflow-tooltip>
            <template slot-scope="scope">
              <el-switch class="zdySwith" :width="82" v-model="scope.row.is_check" active-color="#13ce66" inactive-color="#ffffff" active-text="审核" inactive-text="未审核" active-value="1" @change="getIscheck(scope.row)" inactive-value="0"></el-switch>
            </template>
          </el-table-column>

          <el-table-column label="操作" min-width="215">
            <template slot-scope="scope">
              <el-row class="myblank">
                <el-button :loading="$store.state.isLoading" size="mini" type="danger" plain @click="closeEvent(scope.row.id)">取消活动</el-button>
                <el-button :loading="$store.state.isLoading" size="mini" type="primary" plain @click="updateNews(scope.row.id)">编辑商品</el-button>
                <el-button :loading="$store.state.isLoading" size="mini" type="primary" plain v-if="
                    scope.row.types != 13 &&
                    scope.row.types != 14 &&
                    scope.row.types != 1
                  " @click="updateEvent(scope.row)">编辑活动商品</el-button>
                <el-button :loading="$store.state.isLoading" @click="ewm_show(scope.row.qr)" plain size="mini">二维码</el-button>
                <el-button :loading="$store.state.isLoading" @click="uploadVideo(scope.row.id, scope.row.video)" size="mini" plain v-if="
                    $store.state.plugin.yspdb &&
                    $store.state.plugin.yspdb.is_open == 1
                  ">短视频</el-button>
                <el-button :loading="$store.state.isLoading" size="mini" type="danger" plain @click="deleteShopItem(scope.row.id)">删除</el-button>

                <el-dropdown @command="handleCommand" v-if="scope.row.types != 39 && scope.row.types != 14">
                  <el-button type="success" plain size="mini">
                    进销
                    <i class="el-icon-arrow-down el-icon--right"></i>
                  </el-button>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item :command="toObj(scope.row, '入库')">
                      入库
                    </el-dropdown-item>
                    <el-dropdown-item :command="toObj(scope.row, '调拨')" v-if="
                        is_lifting_stock == 1 ||
                        ($store.state.plugin &&
                          $store.state.plugin.qsps &&
                          $store.state.plugin.qsps.is_open == 1) ||
                        ($store.state.plugin &&
                          $store.state.plugin.qyyy &&
                          $store.state.plugin.qyyy.is_open == 1)
                      ">
                      调拨
                    </el-dropdown-item>
                    <el-dropdown-item :command="toObj(scope.row, '退货')">
                      退货
                    </el-dropdown-item>
                    <el-dropdown-item :command="toObj(scope.row, '记录')">
                      记录
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </el-row>
            </template>
          </el-table-column>
        </el-table>
      </template>
      <template v-slot:footerLeft>
        <el-button :loading="$store.state.isLoading" type="danger" size="mini" @click="deleteLises">
          删除
        </el-button>
        <el-button :loading="$store.state.isLoading" type="success" size="mini" @click="changeCate">
          修改分类
        </el-button>
        <el-button :loading="$store.state.isLoading" type="primary" size="mini" @click="upShow('0')">
          下架
        </el-button>
        <el-button :loading="$store.state.isLoading" type="warning" size="mini" @click="upShow('1')">
          上架
        </el-button>
        <el-button :loading="$store.state.isLoading" type="success" size="mini" @click="changePrice" v-if="$route.query.action == 33">
          修改价格
        </el-button>
      </template>
    </tableComponents>
    <el-dialog :close-on-click-modal="false" title="上传视频" :append-to-body="true" :visible.sync="dialogFormVisible">
      <uploadVideo @send_url="rev_send_url" :pro_src="formVideo.video"></uploadVideo>
    </el-dialog>
    <el-dialog :close-on-click-modal="false" title="二维码" class="tc" :append-to-body="true" :visible.sync="ewmdio" width="370px" center>
      <iframe :src="qr_url" width="75%" height="250" frameborder="0" class="iframe_img"></iframe>
      <span slot="footer" class="dialog-footer">
        <el-button :loading="$store.state.isLoading" @click="ewmdio = false">取 消</el-button>
      </span>
    </el-dialog>
    <el-dialog :close-on-click-modal="false" title="修改活动商品" class="tl size_13" width="800px" :visible.sync="activity_edit">
      <el-form ref="form" label-width="160px">
        <el-form-item label="定金：" v-show="activity == '预售模块'">
          <el-col :span="12">
            <el-input size="small" clearable v-model="activity_form.down_pay" placeholder="请输入定金">
              <!-- <span slot="append"></span> -->
            </el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="发货期：" v-show="activity == '预售模块'">
          <el-col :span="12">
            <el-date-picker v-model="delivery" style="width: 100%" type="date" size="small" placeholder="选择日期"></el-date-picker>
          </el-col>
        </el-form-item>
        <el-form-item label="预售阶梯：" v-show="activity == '预售模块'">
          <el-col :span="20">
            <el-col :span="8">
              <span>单数</span>
            </el-col>
            <el-col :span="2">&nbsp;&nbsp;&nbsp;</el-col>
            <el-col :span="8">
              <span>预售价</span>
            </el-col>
          </el-col>
          <el-col :span="16" v-for="(item, k) in ladder" :key="k">
            <el-col :span="8">
              <el-input size="small" clearable type="number" v-model="item.ladder_num" placeholder="请输入单数" style="width: 100%"></el-input>
            </el-col>
            <el-col :span="2">&nbsp;---&nbsp;</el-col>
            <el-col :span="8">
              <el-input size="small" clearable type="number" v-model="item.ladder_money" @blur="lose_laddermoney(k, item.ladder_money)" placeholder="请输入预售价" style="width: 100%"></el-input>
            </el-col>
            <el-col :span="4">
              <i class="el-icon-delete" style="font-size: 20px; padding-left: 10px" @click="del_presale(item, k)"></i>
            </el-col>
          </el-col>
          <el-col :span="2">
            <el-button :loading="$store.state.isLoading" size="small" type="primary" style="margin-left: 15px" @click="add_presale">增加</el-button>
          </el-col>
        </el-form-item>

        <el-form-item label="砍价次数：" v-show="activity == '好友砍价'">
          <el-col :span="12">
            <el-input size="small" clearable v-model="activity_form.bargain_number" placeholder="请输入砍价次数">
              <!-- <span slot="append"></span> -->
            </el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="单次最低砍价价格：" v-show="activity == '好友砍价'">
          <el-col :span="12">
            <el-input size="small" clearable v-model="activity_form.bargain_begin" placeholder="请输入最低砍价价格">
              <!-- <span slot="append"></span> -->
            </el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="单次最高砍价价格：" v-show="activity == '好友砍价'">
          <el-col :span="12">
            <el-input size="small" clearable v-model="activity_form.bargain_end" placeholder="请输入单次最高砍价价格">
              <!-- <span slot="append"></span> -->
            </el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="最多累计砍价金额：" v-show="activity == '好友砍价'">
          <el-col :span="12">
            <el-input size="small" clearable v-model="activity_form.bargain_price" placeholder="请输入最多累计砍价金额">
              <!-- <span slot="append"></span> -->
            </el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="时间期限（小时）：" v-show="activity == '好友砍价'">
          <el-col :span="12">
            <el-input size="small" clearable v-model="activity_form.bargain_time" placeholder="请输入时间期限（小时）">
              <!-- <span slot="append"></span> -->
            </el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="消耗积分：" v-show="activity == '积分兑换'">
          <el-col :span="12">
            <el-input size="small" clearable v-model="activity_form.score_rob" placeholder="请输入消耗积分">
              <!-- <span slot="append"></span> -->
            </el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="所属分类：" v-show="activity == '积分兑换'">
          <el-col :span="12">
            <el-select v-model="activity_form.integral_cate" size="small" clearable placeholder="请选择" style="width: 100%">
              <el-option v-for="(item, i) in integralCateLists" :key="i" :label="item.title" :value="item.id"></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <el-form-item label="商品折扣：" v-show="activity == '限时特惠'">
          <el-col :span="12">
            <el-input size="small" clearable v-model="activity_form.discount_rob" placeholder="请输入商品折扣">
              <span slot="append">折</span>
            </el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="商品数量：" v-show="activity == '限时特惠'">
          <el-col :span="12">
            <el-input size="small" clearable v-model="activity_form.discount_limit" placeholder="请输入活动商品数量">
              <!-- <span slot="append"></span> -->
            </el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="选择时区：" v-show="activity == '限时特惠'">
          <el-col :span="12">
            <el-select v-model="activity_form.time_id" size="small" clearable placeholder="请选择" style="width: 100%">
              <el-option v-for="(item, i) in time_option" :key="i" :label="item.time_str" :value="item.id"></el-option>
            </el-select>
          </el-col>
        </el-form-item>
        <template v-if="activity == '拼团购物'">
          <el-form-item label="拼团人数：">
            <el-col :span="12">
              <el-input size="small" clearable type="number" v-model="activity_form.group_people" placeholder="请输入拼团人数">
                <!-- <span slot="append"></span> -->
              </el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="拼团折扣：">
            <el-col :span="12">
              <el-input size="small" clearable type="number" v-model="activity_form.group_discount" placeholder="请输入拼团折扣">
                <span slot="append">折</span>
              </el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="拼团时间：">
            <el-col :span="12">
              <el-input size="small" clearable type="number" v-model="activity_form.group_time" placeholder="请输入拼团时间">
                <span slot="append">小时</span>
              </el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="团长免单：">
            <el-col :span="12">
              <el-switch class="zdySwith" :width="82" v-model="activity_form.group_face" active-color="#1aad19" inactive-color="#ffffff" active-text="是" inactive-text="否" active-value="1" inactive-value="0"></el-switch>
            </el-col>
          </el-form-item>
        </template>

        <template v-if="
            activity == '线下核销会员商品' || activity == '线下核销普通商品'
          ">
          <el-form-item label="核销次数：">
            <el-col :span="12">
              <el-input size="small" clearable type="number" v-model="activity_form.write_number" placeholder="请输入核销次数">
                <span slot="append">次</span>
              </el-input>
            </el-col>
          </el-form-item>

          <el-form-item label="核销金额：">
            <el-col :span="12">
              <el-input size="small" clearable type="number" v-model="activity_form.write_reward" placeholder="请输入每次核销奖励核销人金额">
                <span slot="append">元</span>
              </el-input>
            </el-col>
          </el-form-item>
        </template>
        <!-- 竞拍 -->
        <template v-if="activity_form.types == '18'">
          <el-form-item label="竞拍方式：">
            <el-col :span="8">
              <el-radio-group v-model="activity_form.auction_types">
                <el-radio label="0">提价拍</el-radio>
                <el-radio label="1">降价拍</el-radio>
              </el-radio-group>
            </el-col>
            <el-col :span="16">
              提价拍：起拍价需小于流拍价 | 降价拍：起拍价需大于流拍价
            </el-col>
          </el-form-item>

          <el-form-item label="起拍价：">
            <el-col :span="12">
              <el-input size="small" clearable type="number" v-model="activity_form.starting_price" placeholder="请输入起拍价">
                <span slot="append">元</span>
              </el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="流拍价：">
            <el-col :span="12">
              <el-input size="small" clearable type="number" v-model="activity_form.auction_price" placeholder="请输入流拍价">
                <span slot="append">元</span>
              </el-input>
            </el-col>
          </el-form-item>

          <el-form-item label="加减幅度价格：">
            <el-col :span="8">
              <el-input size="small" clearable type="number" v-model="activity_form.auction_amplitude" placeholder="最低加减幅度">
              </el-input>
            </el-col>
            <el-col :span="1" style="text-align: center"> ~ </el-col>
            <el-col :span="8">
              <el-input size="small" clearable type="number" v-model="activity_form.auction_amplitude_max" placeholder="最高加减幅度">
              </el-input>
            </el-col>
            <span style="padding-left: 10px">元</span>
          </el-form-item>

          <el-form-item label="保证金：">
            <el-col :span="12">
              <el-input size="small" clearable type="number" v-model="activity_form.auction_margin" placeholder="请输入保证金">
              </el-input>
              <!-- <span style="padding-left:10px;"></span> -->
            </el-col>
          </el-form-item>

          <el-form-item label="开始时间：">
            <el-col :span="12">
              <el-date-picker size="small" v-model="auction_open_time" type="datetime" style="width: 100%" placeholder="选择开始时间">
              </el-date-picker>
              <!-- <span style="padding-left:10px;"></span> -->
            </el-col>
          </el-form-item>

          <el-form-item label="结束时间：">
            <el-col :span="12">
              <el-input size="small" clearable type="number" style="width: 100%" v-model="activity_form.auction_end_time" placeholder="请输入结束时间">
                <span slot="append">分钟</span>
              </el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="下一轮开始时间：">
            <el-col :span="12">
              <el-input size="small" clearable type="number" v-model="activity_form.auction_next_time" placeholder="请输入下一轮开始时间">
                <span slot="append">分钟</span>
              </el-input>
            </el-col>
          </el-form-item>
        </template>

        <!-- 拼购 -->
        <template v-if="activity_form.types == '19'">
          <el-form-item label="拼购分类：">
            <el-col :span="12">
              <el-select v-model="activity_form.gbc_id" size="small" clearable placeholder="请选择" style="width: 100%">
                <el-option v-for="(item, i) in groupbuyCateList" :key="i" :label="item.title" :value="item.id"></el-option>
              </el-select>
            </el-col>
          </el-form-item>
        </template>
        <!-- 公排-->
        <template v-if="activity_form.types == '8'">
          <el-form-item label="公排权值：" v-show="activity_form.types == '8'">
            <el-col :span="12">
              <el-input size="small" clearable v-model="activity_form.platoon" placeholder="请输入赠送的公排权值"></el-input>
              <!-- <span style="padding-left:10px;"></span> -->
            </el-col>
          </el-form-item>
        </template>
        <!-- 零元购 -->
        <template v-if="activity_form.types == '24'">
          <el-form-item label="邮费：">
            <el-col :span="12">
              <el-input size="small" clearable v-model="activity_form.zeromail" placeholder="请输入零元购邮费"></el-input>
              <!-- <span style="padding-left:10px;"></span> -->
            </el-col>
          </el-form-item>
        </template>
        <el-form-item>
          <el-button :loading="$store.state.isLoading" type="primary" @click="edit_activity()">修改</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <el-dialog :close-on-click-modal="false" title="批量修改商品分类" :append-to-body="true" :visible.sync="showCate" width="600px" center>
      <el-form>
        <el-form-item label="商品栏目" style="margin-bottom: 0px">
          <el-col :span="14">
            <el-col :span="24" v-for="(domain, index) in formLabelAlign" :key="index">
              <el-col :span="20" class="mr">
                <el-cascader :options="cate_option" :props="optionProps" :show-all-levels="false" change-on-select style="width: 100%" v-model="domain.value" placeholder="请选择栏目"></el-cascader>
              </el-col>

              <el-col :span="1" v-if="index == 0">
                <el-button :loading="$store.state.isLoading" @click="addDomain" type="primary" icon="el-icon-plus"></el-button>
              </el-col>
              <el-col :span="1" v-if="index > 0">
                <el-button :loading="$store.state.isLoading" @click.prevent="removeDomain(domain)" type="danger" icon="el-icon-delete"></el-button>
              </el-col>
            </el-col>
          </el-col>
        </el-form-item>
        <el-form-item label="商品：">
          <el-col>
            <el-tag v-for="(tag, t) in pid_str_cn" :key="t" closable style="margin: 0 10px" @close="delPidCn(t)">
              {{ tag }}
            </el-tag>
          </el-col>
        </el-form-item>
        <el-form-item>
          <el-col class="lh size_12 sizeColor">
            <div>
              PS：选择商品相关分类，点击选择栏目左侧 "[+]"
              可增加所属分类选择器，就是指一个产品可以放在多个分类下
            </div>
          </el-col>
        </el-form-item>
        <div class="tc" style="width: 100%">
          <el-button :loading="$store.state.isLoading" type="primary" @click="changeCateBtn">
            确定
          </el-button>
        </div>
      </el-form>
    </el-dialog>

    <el-dialog :close-on-click-modal="false" title="修改价格" :lock-scroll="true" :visible.sync="changePriceShow" class="tl size_13" width="600px">
      <el-form :model="changePriceInfo" class="mar_top" label-width="120px">
        <el-form-item label="类型1：">
          <el-col :span="18">
            <el-radio-group v-model="changePriceInfo.type_1">
              <el-radio label="0">金额[元]</el-radio>
              <el-radio label="1">比例[百分比]</el-radio>
            </el-radio-group>
          </el-col>
        </el-form-item>

        <el-form-item label="类型2：">
          <el-col :span="18">
            <el-radio-group v-model="changePriceInfo.type_2">
              <el-radio label="0">加</el-radio>
              <el-radio label="1">减</el-radio>
            </el-radio-group>
          </el-col>
        </el-form-item>

        <el-form-item label="数量[销售价]：">
          <el-col :span="18">
            <el-input v-model="changePriceInfo.num" clearable size="small"></el-input>
          </el-col>
        </el-form-item>

        <el-form-item label="数量[成本价]：">
          <el-col :span="18">
            <el-input v-model="changePriceInfo.num1" clearable size="small"></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="数量[市场价]：">
          <el-col :span="18">
            <el-input v-model="changePriceInfo.num2" clearable size="small"></el-input>
          </el-col>
        </el-form-item>

        <el-form-item>
          <el-button :loading="$store.state.isLoading" type="primary" @click="subChangePrice">确定</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <xzShop :show="showshop" v-if="showshop" :isAll="false" showType="table" @sendShop="getSend" @isshow="getShow">
    </xzShop>

    <el-dialog :close-on-click-modal="false" title="采集" :modal-append-to-body="false" :visible.sync="jh_show" class="size_13" width="500px">
      <el-row class="progress_div">
        <el-col :span="24" class="mar_bottom_25">
          第{{ jh_info.page || 1 }}页采集中，请等待...
        </el-col>
        <el-col :span="24">
          <el-button :loading="$store.state.isLoading" v-if="jh_time" size="medium" type="primary" @click.prevent="cjjhgylcp_jx">
            继续采集
          </el-button>
        </el-col>
      </el-row>
    </el-dialog>
  </div>
</template>
<script>
import xzShop from "@/components/currency/xz_shop.vue";
import { actionEvent } from "@/assets/js/searchData/searchData"; //引入搜索的数据
import uploadVideo from "@/components/currency/uploadvideo";
import axios from "axios";
import qs from "qs";
var md5 = require("md5");
export default {
  name: "event_shop",
  data() {
    return {
      auction_open_time: "",
      showshop: false,
      ladder: [],
      delivery: "",
      qr_url: "",
      time_option: [], //时区
      activity_option: {}, //活动场景
      activity_edit: false,
      activity_form: {},
      activity: "", //活动场景
      types: "",
      shop_list: {
        data: [],
      },
      multipleSelection: [],
      loading: false,
      pagesize: 10,
      currentPage: 1,
      Video: "",
      formVideo: {
        video: "",
        id: "",
      },
      dialogFormVisible: false,
      videoFlag: false, //刚开始的时候显示为flase
      videoUploadPercent: "0%", //进度条刚开始的时候为0%
      ewmdio: false,
      groupbuyCateList: {},
      searchAll: {},
      actionSearchData: actionEvent,
      integralCateLists: {},
      pid_str: [],
      pid_str_cn: [],
      showCate: false,
      formLabelAlign: [{ value: [] }],
      cate_option: [],
      optionProps: {
        value: "id",
        label: "title",
        children: "z",
      },
      changePriceShow: false,
      changePriceInfo: {},
      jh_show: false,
      jh_info: {},
      jh_time: false,
      is_lifting_stock: 0,
    };
  },
  components: {
    xzShop,
    uploadVideo,
  },
  created() {
    this.types = this.$route.query.action || "2";
    this.get_activity_option();
    this.get_shoplist();
    if (this.$route.query.action == 19) {
      this.getGroupBuyCate();
    }
    if (this.$route.query.action == 2) {
      this.getIntegralCate();
    }
    this.$api.getSettings
      .findConfig({ iden: "is_lifting_stock" })
      .then((res) => {
        if (res.data.code == 200) {
          this.is_lifting_stock = res.data.result;
        }
      });
  },
  methods: {
    handleCommand(command) {
      var str = command.commandStr;
      switch (str) {
        case "入库":
          this.$store.commit("addbreadcrumbs", {
            title: "操作入库",
            url: `/index/shop/operation_stock?pid=${command.id}&types${command.types}`,
          });
          this.$router.push({
            path: "/index/shop/operation_stock",
            query: {
              pid: command.id,
              types: command.types,
            },
          });
          break;
        case "调拨":
          this.$store.commit("addbreadcrumbs", {
            title: "库存调拨",
            url: `/index/shop/allocation_stock?pid=` + command.id,
          });
          this.$router.push({
            path: "/index/shop/allocation_stock",
            query: {
              pid: command.id,
            },
          });
          break;
        case "退货":
          this.$store.commit("addbreadcrumbs", {
            title: "退货管理",
            url: `/index/shop/refund_stock?pid=` + command.id,
          });
          this.$router.push({
            path: "/index/shop/refund_stock",
            query: {
              pid: command.id,
            },
          });
          break;
        case "记录":
          this.$store.commit("addbreadcrumbs", {
            title: "流水记录",
            url: `/index/shop/product_stock?pid=` + command.id,
          });
          this.$router.push({
            path: "/index/shop/product_stock",
            query: {
              pid: command.id,
            },
          });
          break;
      }
    },
    toObj(obj, str) {
      obj = obj || {};
      obj = JSON.parse(JSON.stringify(obj));
      obj.commandStr = str;
      return JSON.parse(JSON.stringify(obj));
    },
    clearshop() {
      this.$swal({
        title: "您确定要清空供应链商品吗",
        text: "请谨慎操作！",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "是的，我要清空",
        cancelButtonText: "容我三思",
      }).then((willDelete) => {
        if (willDelete.value) {
          this.$api.getAdmin.clear_supply_chain({}).then((res) => {
            if (res.data.code == 200) {
              this.$swal("清空成功！", "您已经删除了这些信息。", "success");
              this.get_shoplist(1);
            } else {
              this.$swal("清空失败！", res.data.result, "error");
            }
          });
        }
      });
    },
    cjjhgylcp_jx() {
      this.jh_time = false;
      this.cjjhgylcp_page();
    },
    cjjhgylcp() {
      this.jh_page = 1;
      this.jh_show = true;
      this.jh_info = {
        page: 1,
      };
      this.cjjhgylcp_page();
    },
    cjjhgylcp_page() {
      if (this.jh_show != true) {
        return;
      }
      var params = {};
      params = JSON.parse(JSON.stringify(this.jh_info)) || {};
      var uid = localStorage.getItem("adminuid") || "";
      var time = parseInt(new Date().getTime() / 1000) + "";
      var admin_key = localStorage.getItem("admin_key") || "";
      var str = qs.stringify(params);
      var url = "";
      if (str == "") {
        url =
          "admin_key=" +
          admin_key +
          "&headuid=" +
          uid +
          "&timestamp=" +
          time +
          "&meid=" +
          "" +
          "&extra=" +
          "";
      } else {
        url =
          str +
          "&admin_key=" +
          admin_key +
          "&headuid=" +
          uid +
          "&timestamp=" +
          time +
          "&meid=" +
          "" +
          "&extra=" +
          "";
      }
      var arr = url.split("&");
      for (var i in arr) {
        if (arr[i].indexOf("%") >= 0) {
          arr[i] = decodeURIComponent(arr[i]);
        }
      }
      var urlStr = arr.sort().join("&");
      params.sign = md5("@" + urlStr + "@");

      axios
        .post("/api/admin/supply_chain/product", qs.stringify(params), {
          headers: {
            headuid: uid,
            timestamp: time,
            meid: "",
            extra: "",
          },
          timeout: 10000000,
        })
        .then((res) => {
          if (res.data.code == 200) {
            if (!isNaN(res.data.result) && res.data.result !== true) {
              this.jh_info.page = Number(res.data.result) + 1;
              this.cjjhgylcp_page();
            } else {
              this.jh_show = false;
              this.$fnc.alertSuccess({ text: "采集完成" });
            }
          } else {
            this.jh_time = true;
            this.$fnc.alertError(res.data.code_desc, res.data.result);
          }
        });
    },
    subChangePrice() {
      this.$swal({
        title: "您确定要修改这些商品的价格吗",
        text: "请谨慎操作！",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "是的，我要修改",
        cancelButtonText: "容我三思",
      }).then((willDelete) => {
        if (willDelete.value) {
          this.$api.getShops
            .product_change_price(this.changePriceInfo)
            .then((res) => {
              if (res.data.status == 1 && res.data.code == 200) {
                this.changePriceShow = false;
                this.$fnc.alertSuccess({ text: "修改成功" });
                this.get_shoplist();
              } else {
                this.$fnc.alertError(res.data.code_desc, res.data.result);
              }
            });
        }
      });
    },
    changePrice() {
      var id_str = "";
      if (this.multipleSelection.length <= 0) {
        this.$message.error("未选择批量删除");
      } else {
        for (var i in this.multipleSelection) {
          id_str += this.multipleSelection[i].id + "@";
        }
        id_str = id_str.slice(0, -1);
        this.changePriceInfo = {
          id_str: id_str,
          type_1: "",
          type_2: "",
          num: "",
          num1: "",
          num2: "",
        };
        this.changePriceShow = true;
      }
    },
    upShow(show) {
      if (this.multipleSelection.length != 0) {
        var id_str = "";
        var title = show == "1" ? "上架成功" : "下架成功";
        var params = {};
        for (var i in this.multipleSelection) {
          id_str += this.multipleSelection[i].id + "@";
        }
        params.show_type = show;
        params.id_str = id_str;
        this.$api.getShops.updateAll(params).then((res) => {
          if (res.data.code == 200) {
            this.get_shoplist();
            this.$fnc.alertSuccess({ text: title });
          } else {
            this.$fnc.alertError(res.data.code_desc, res.data.result);
          }
        });
      }
    },
    addDomain() {
      this.formLabelAlign.push({
        value: [],
        key: Date.now(),
      });
    },
    removeDomain(item) {
      var index = this.formLabelAlign.indexOf(item);
      if (index !== -1) {
        this.formLabelAlign.splice(index, 1);
      }
    },
    delPidCn(index) {
      this.pid_str.splice(index, 1);
      this.pid_str_cn.splice(index, 1);
    },
    changeCateBtn() {
      this.$swal({
        title: "您确定要修改这些商品的分类吗",
        text: "请谨慎操作！",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "是的，我要修改",
        cancelButtonText: "容我三思",
      }).then((willDelete) => {
        if (willDelete.value) {
          var data = {};
          data.pid_str = this.pid_str.join("@");
          var cate_Arr = this.formLabelAlign;
          var cate_ar = [];
          for (var i in cate_Arr) {
            cate_ar.push(cate_Arr[i].value[cate_Arr[i].value.length - 1]);
          }
          data.cate_ar = cate_ar.join("@");
          this.$api.getShops.product_saveedit_cate(data).then((res) => {
            if (res.data.code == 200) {
              this.showCate = false;
              this.pid_str = "";
              this.pid_str_cn = "";
              this.$swal("修改成功！", "您已经删除了这些信息。", "success");
              this.get_shoplist();
            } else {
              this.$swal("修改失败！", res.data.result, "error");
            }
          });
        }
      });
    },
    changeCate() {
      var str = [];
      var str1 = [];
      if (this.multipleSelection.length <= 0) {
        this.$message.error("未选择批量删除");
      } else {
        var params = {};
        params.parent_id = "";
        this.$api.getShops.getProductCateTreeList(params).then((res) => {
          if (res.data.code == 200 && res.data.status == 1 && res.data.result) {
            this.cate_option = res.data.result;
          }
        });
        for (var i in this.multipleSelection) {
          str.push(this.multipleSelection[i].id);
          str1.push(this.multipleSelection[i].title);
        }
        this.pid_str = str;
        this.pid_str_cn = str1;
        this.showCate = true;
      }
    },
    rev_send_url(val) {
      var params = {};
      this.formVideo.video = val.video_url;
      this.formVideo.video_pic = val.video_pic;
      this.formVideo.vid = val.video_id;
      params = this.formVideo;
      this.$api.getShops.setVideo(params).then((res) => {
        if (res.data.code == 200) {
          this.$fnc.alertSuccess({ text: "提交成功" });
          this.dialogFormVisible = false;
          this.$store.dispatch("getShopsAll", this.searchAll);
        } else {
          this.$fnc.alertError(res.data.code_desc, res.data.result);
        }
      });
    },
    getIntegralCate() {
      this.$api.getShops.integral_cate_lists_all({}).then((res) => {
        if (res.data.code == 200) {
          this.integralCateLists = res.data.result;
        }
      });
    },
    getSearch(obj) {
      this.searchAll = obj;
      this.get_shoplist(1);
    },
    getGroupBuyCate() {
      this.$api.getGroupbuy.getGroupbuyCateAll({}).then((res) => {
        if (res.data.code == 200) {
          this.groupbuyCateList = res.data.result;
        }
      });
    },
    getIscheck(info) {
      var params = {};
      params.check_type = info.is_check;
      params.id_str = info.id;
      this.$api.getShops.updateCheck(params).then((res) => {
        if (res.data.code == 200 && res.data.result) {
          this.$fnc.alertSuccess("审核成功");
        } else {
          this.$fnc.alertError(res.data.code_desc, res.data.result);
        }
      });
    },
    getIsup(info) {
      var params = {};
      params.show_type = info.show;
      params.id_str = info.id;
      this.$api.getShops.updateAll(params).then((res) => {
        if (res.data.code == 200) {
          this.$fnc.alertSuccess("上架成功");
        } else {
          this.$fnc.alertError(res.data.code_desc, res.data.result);
        }
      });
    },
    getSend(row) {
      if (row.id == 0) {
        this.$fnc.alertError("请指定商品ID");
      } else {
        this.$swal({
          title: "添加会员商品",
          text: row.title,
          type: "success",
          showCancelButton: true,
          confirmButtonColor: "#DD6B55",
          confirmButtonText: "是的，我要添加",
          cancelButtonText: "容我三思",
        }).then((willDelete) => {
          if (willDelete.value) {
            var params = {};
            params.types = 1;
            params.id = row.id;
            this.$api.getShops.add_event(params).then((res) => {
              if (res.data.code == 200) {
                this.$fnc.alertSuccess("添加成功");
                this.get_shoplist();
              } else {
                this.$fnc.alertError(res.data.result);
              }
            });
          }
        });
      }
    },
    getShow(val) {
      this.showshop = val;
    },
    add_btn() {
      let path = "";
      if (this.$route.query.action == 1) {
        path = "/index/shop/add_vipproduct";
      }else if (this.$route.query.action == 42) {
        path = `/index/shop/addLockProduct?types=${this.$route.query.action}`;
      } else {
        path = `/index/shop/addproduct?types=${this.$route.query.action}`;
      }
      this.$store.commit("setShopsItemId", "");
      let routeData = this.$router.resolve({
        path: path,
      });
      window.open(routeData.href, "_blank");
    },
    toParst(JSONarr) {
      console.log(JSONarr);
      if (JSONarr) {
        return JSON.parse(JSONarr);
      }
    },
    lose_laddermoney(l, money) {
      if (Number(money) <= this.activity_form.down_pay) {
        this.$fnc.alertError("预售价不能小于定金");
        this.ladder[l].ladder_money = this.activity_form.down_pay;
      }
    },
    del_presale(item, k) {
      this.ladder.splice(k, 1);
    },
    add_presale() {
      var obj = {
        ladder_num: "",
        ladder_money: "",
      };
      this.ladder.push(obj);
    },
    ewm_show(qr) {
      this.ewmdio = true;
      this.qr_url = qr;
    },
    updateNews(id) {
      let routeData;
      if (this.$route.query.action == "1") {
        routeData = this.$router.resolve({
          path: "/index/shop/add_vipproduct",
          query: { id: id },
        });
      } else if (this.$route.query.action == "42") {
        routeData = this.$router.resolve({
          path: "/index/shop/addLockProduct",
          query: { id: id },
        });
      } else {
        routeData = this.$router.resolve({
          path: "/index/shop/addproduct",
          query: { id: id, types: this.$route.query.action },
        });
      }

      window.open(routeData.href, "_blank");
    },
    edit_activity() {
      var params = {};
      params.id = this.activity_form.id;
      if (this.types == "2") {
        params.score_rob = this.activity_form.score_rob;
        params.integral_cate = this.activity_form.integral_cate;
        this.$api.getShops.edit_integralshop(params).then((res) => {
          if (res.data.code == 200) {
            this.$fnc.alertSuccess("修改成功");
            this.get_shoplist();
            this.activity_edit = false;
          } else {
            this.$fnc.alertError(res.data.result);
            this.activity_edit = false;
          }
        });
      } else if (this.types == "7") {
        params.time_id = this.activity_form.time_id;
        params.discount_limit = this.activity_form.discount_limit;
        params.discount_rob = this.activity_form.discount_rob;
        this.$api.getShops.edit_limitshop(params).then((res) => {
          if (res.data.code == 200) {
            this.$fnc.alertSuccess("修改成功");
            this.get_shoplist();
            this.activity_edit = false;
          } else {
            this.$fnc.alertError(res.data.result);
            this.activity_edit = false;
          }
        });
      } else if (this.types == "4") {
        this.$api.getShops.editGroup(this.activity_form).then((res) => {
          if (res.data.code == 200) {
            this.$fnc.alertSuccess("修改成功");
            this.get_shoplist();
            this.activity_edit = false;
          } else {
            this.$fnc.alertError(res.data.result);
            this.activity_edit = false;
          }
        });
      } else if (this.types == "3") {
        params.bargain_number = this.activity_form.bargain_number;
        params.bargain_begin = this.activity_form.bargain_begin;
        params.bargain_end = this.activity_form.bargain_end;
        params.bargain_time = this.activity_form.bargain_time;
        params.bargain_price = this.activity_form.bargain_price;

        this.$api.getShops.edit_cut(params).then((res) => {
          if (res.data.code == 200) {
            this.$fnc.alertSuccess("修改成功");
            this.get_shoplist();
            this.activity_edit = false;
          } else {
            this.$fnc.alertError(res.data.result);
            this.activity_edit = false;
          }
        });
      } else if (this.types == "6") {
        var flag = false;
        this.ladder.forEach((item) => {
          if (Number(item.ladder_money) <= this.activity_form.down_pay) {
            this.$fnc.alertError("预售价不能小于定金");
            flag = true;
          }
        });
        if (flag) {
          return;
        }
        params.down_pay = this.activity_form.down_pay;
        params.delivery_date = this.activity_form.delivery_date;
        params.ladder = JSON.stringify(this.ladder);
        this.$api.getShops.edit_presale(params).then((res) => {
          if (res.data.code == 200) {
            this.$fnc.alertSuccess("修改成功");
            this.get_shoplist();
            this.activity_edit = false;
          } else {
            this.$fnc.alertError(res.data.result);
            this.activity_edit = false;
          }
        });
      } else if (this.types == "10" || this.types == "11") {
        params.write_number = this.activity_form.write_number;
        params.write_reward = this.activity_form.write_reward;

        this.$api.getShops.edit_write(params).then((res) => {
          if (res.data.code == 200) {
            this.$fnc.alertSuccess("修改成功");
            this.get_shoplist();
            this.activity_edit = false;
          } else {
            this.$fnc.alertError(res.data.result);
            this.activity_edit = false;
          }
        });
      } else if (this.types == "18") {
        this.$api.getShops.edit_eventauction(this.activity_form).then((res) => {
          if (res.data.code == 200) {
            this.$fnc.alertSuccess("修改成功");
            this.get_shoplist();
            this.activity_edit = false;
          } else {
            this.$fnc.alertError(res.data.result);
            this.activity_edit = false;
          }
        });
      } else if (this.types == "19") {
        params.gbc_id = this.activity_form.gbc_id;
        this.$api.getGroupbuy.editGroupBbuy(params).then((res) => {
          if (res.data.code == 200) {
            this.$fnc.alertSuccess("修改成功");
            this.get_shoplist();
            this.activity_edit = false;
          } else {
            this.$fnc.alertError(res.data.result);
            this.activity_edit = false;
          }
        });
      } else if (this.types == "8") {
        params.platoon = this.activity_form.platoon;
        this.$api.getShops.edit_platoon(params).then((res) => {
          if (res.data.code == 200) {
            this.$fnc.alertSuccess("修改成功");
            this.get_shoplist();
            this.activity_edit = false;
          } else {
            this.$fnc.alertError(res.data.result);
            this.activity_edit = false;
          }
        });
      } else if (this.types == "24") {
        params.zeromail = this.activity_form.zeromail;
        this.$api.getShops.edit_zero(params).then((res) => {
          if (res.data.code == 200) {
            this.$fnc.alertSuccess("修改成功");
            this.get_shoplist();
            this.activity_edit = false;
          } else {
            this.$fnc.alertError(res.data.result);
            this.activity_edit = false;
          }
        });
      }
    },
    updateEvent(item) {
      item = JSON.parse(JSON.stringify(item));
      this.activity_edit = true;
      item.group_discount = this.$fnc.toFixedZ(Number(item.group_discount));
      item.write_reward = this.$fnc.toFixedZ(Number(item.write_reward));

      item.starting_price = this.$fnc.toFixedZ(Number(item.starting_price));
      item.auction_price = this.$fnc.toFixedZ(Number(item.auction_price));
      item.auction_amplitude = this.$fnc.toFixedZ(
        Number(item.auction_amplitude)
      );
      item.auction_amplitude_max = this.$fnc.toFixedZ(
        Number(item.auction_amplitude_max)
      );
      item.auction_margin = this.$fnc.toFixedZ(Number(item.auction_margin));
      item.platoon = this.$fnc.toFixedZ(Number(item.platoon));
      item.bargain_begin = this.$fnc.toFixedZ(Number(item.bargain_begin));
      item.bargain_end = this.$fnc.toFixedZ(Number(item.bargain_end));
      item.bargain_price = this.$fnc.toFixedZ(Number(item.bargain_price));
      this.activity_form = item;

      if (item.types == 6) {
        this.delivery = new Date(parseInt(item.delivery_date) * 1000);
        this.ladder = JSON.parse(item.ladder);
      }
      if (item.types == 18) {
        this.auction_open_time = new Date(
          parseInt(item.auction_open_time) * 1000
        );
      }
    },
    get_activity_option() {
      this.$api.getShops.get_activitylist({}).then((res) => {
        if (res.data.code == 200) {
          this.activity_option = res.data.result;
          for (var k in this.activity_option) {
            this.types == k ? (this.activity = this.activity_option[k]) : "";
          }
        }
      });
      this.$api.getShops.get_limittime({}).then((res) => {
        if (res.data.code == 200) {
          this.time_option = res.data.result;
          this.time_option.forEach((item) => {
            var str1 = this.getTimeFormat(item.begin_time);
            var str2 = this.getTimeFormat(item.end_time);
            item.time_str = str1 + "---" + str2;
          });
        }
      });
    },

    getTimeFormat(time) {
      //time 1398250549490
      //时间数字转2014-04-23 18:55:49 格式
      // php 后端时间戳返回10位数，补3个 000
      if (time == "0" || time == "0000") {
        return "----";
      }
      time = time + "";
      var date = "";
      if (time.length >= 13) {
        date = new Date(parseInt(time));
      } else {
        date = new Date(parseInt(time + "000"));
      }
      var Y = date.getFullYear() + "-";
      var M =
        (date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1) + "-";
      var D =
        (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
      var h =
        (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
      var m =
        (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) +
        ":";
      var s =
        date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
      return Y + M + D + h + m + s;
    },

    uploadVideo(id, video) {
      this.dialogFormVisible = true;
      this.formVideo.id = id;
      this.formVideo.video = video || "";
    },

    closeEvent(id) {
      this.$swal({
        title: "您确定要取消活动吗?",
        text: "该活动商品下,所有未完成的订单会关闭并退款!(仅支持：拼购活动)",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "是的，我要取消",
        cancelButtonText: "容我三思",
      }).then((willDelete) => {
        if (willDelete.value) {
          var data = { id };
          this.$api.getShops.closeEvent(data).then((res) => {
            if (res.data.code == 200) {
              this.$swal(
                "取消成功！",
                "您已经取消了这个商品的活动。",
                "success"
              );
              this.$store.dispatch("getShopsAll", this.searchAll);
              this.get_shoplist(1);
            } else {
              this.$fnc.alertError("取消失败！", res.data.result);
            }
          });
        }
      });
    },
    deleteShopItem(id) {
      this.$swal({
        title: "您确定要删除这条信息吗",
        text: "删除后将无法恢复，请谨慎操作！",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "是的，我要删除",
        cancelButtonText: "容我三思",
      }).then((willDelete) => {
        if (willDelete.value) {
          var data = { id };
          this.$api.getShops.deleteShopItem(data).then((res) => {
            if (res.data.code == 200) {
              this.$swal("删除成功！", "您已经删除了这条信息。", "success");
              this.$store.dispatch("getShopsAll", this.searchAll);
              this.get_shoplist(1);
            } else {
              this.$fnc.alertError("删除失败！", res.data.result);
            }
          });
        }
      });
    },
    deleteLises() {
      //批量删除
      var str = "";
      if (this.multipleSelection.length <= 0) {
        this.$message.error("未选择批量删除");
      } else {
        for (var i in this.multipleSelection) {
          str += this.multipleSelection[i].id + "@";
        }
        // str = str.slice(0,-1);
        this.$swal({
          title: "您确定要删除这些信息吗",
          text: "删除后将无法恢复，请谨慎操作！",
          type: "warning",
          showCancelButton: true,
          confirmButtonColor: "#DD6B55",
          confirmButtonText: "是的，我要删除",
          cancelButtonText: "容我三思",
        }).then((willDelete) => {
          if (willDelete.value) {
            var data = { id_str: str };
            this.$api.getShops.deleteShopItemsAll(data).then((res) => {
              if (res.data.code == 200) {
                this.$swal("删除成功！", "您已经删除了这些信息。", "success");
                this.$store.dispatch("getShopsAll", this.searchAll);
                this.get_shoplist(1);
              } else {
                this.$swal("删除失败！", res.data.result, "success");
              }
            });
          }
        });
      }
    },
    sorta(a, b) {
      return b - a;
    },
    sortNew(index, row) {
      var params = {};
      params.id = row.id;
      params.sort = row.sort;
      this.$api.getShops.sortProduct(params).then((res) => {
        if (res.data.code == 200 && res.data.result) {
          this.$store.dispatch("getShopsAll", this.searchAll);
          this.get_shoplist(1);
        } else {
          this.$fnc.alertError(res.data.code_desc, res.data.result); //失败弹出框
        }
      });
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },

    // 初始页currentPage、初始每页数据数pagesize和数据data
    handleSizeChange: function (size) {
      //每页下拉显示数据
      this.pagesize = size;
      this.get_shoplist(1);
    },
    handleCurrentChange: function (currentPage) {
      //点击第几页
      this.currentPage = parseInt(currentPage);
      this.get_shoplist(this.currentPage);
    },
    get_shoplist(page) {
      this.loading = true;
      var params = {};
      params = this.searchAll || {};
      params.page = page;
      params.page_size = this.pagesize;
      params.types = this.types;
      this.$api.getShops.getShopsList(params).then((res) => {
        if (res.data.code == 200) {
          this.shop_list = res.data.result;
          this.loading = false;
        } else {
          this.$fnc.alerterror(res.data.result);
          this.loading = false;
        }
      });
    },
  },
  watch: {
    auction_open_time(val) {
      var time = val.getTime();
      this.activity_form.auction_open_time = this.$fnc.phptime(time);
    },
    delivery(val) {
      var time = val.getTime();
      this.activity_form.delivery_date = this.$fnc.phptime(time);
    },
    $route() {
      this.types = this.$route.query.action || "2";
      this.get_activity_option();
      this.get_shoplist();
    },
  },
};
</script>
<style scoped>
.presale {
  width: 50%;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  text-align: left;
}

.presale span {
  width: 50%;
  font-weight: normal;
}

.presale div {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  text-align: left;
}
</style>
